import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=(int)(Math.random()*100+1);
        int c=7;
        while (true) {
            if (c == 0) {
                System.out.println(" 你的机会用完了"+"是否再玩一局,是:y,否:y以外的字符串");
                String qr = sc.next();
                if(qr.equals(" y")){
                    a = (int) (Math.random() * 100 + 1);
                    c=7;
                }else{
                    break;
                }
            }
            System.out.println(" 请输入1到100的数");
            int i = sc.nextInt();
            if (i == a) {
                System.out.println(" 猜对了");
                break;
            }
            if (i > a) {
                c--;
                System.out.println(" 大了你还有" + c + "机会");
            } else if(i < a){
                c--;
                System.out.println("小了你还有" + c + "机会");
            }
        }
    }
}
